<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>文章修改</title>
    <link rel="stylesheet" href="/static/admin/css/style.css">
</head>
<body>

<div class="content">
    <div class="wrap cl">
        <!--导航栏-->
        {(admin/nav.html)}
        <!--导航栏-->

        <!--列表样式2-->

        <div class="details">
            <h3 class="details-title border-b">文章修改</h3>
            <div class="verify cl">
                <div class="verify-item personal" style="display: block;">
                    <form action="/admin/post_edit_submit"  method="post" target="_blank">

                        <input type="hidden" name="id" value="{{posts.id}}" />

                        <div class="verify-item-t">
                            <div style="height: 10px;"></div>
                            <p class="title">基本信息</p>
                            <dl>
                                <dt>文章标题：</dt>
                                <dd><input type="text" name="title" value="{{posts.title}}" /></dd>
                            </dl>

                            <dl>
                                <dt>属性：</dt>
                                <dd>
                                    <select name="flag">
                                        {% if posts.flag == 0 then %}
                                            <option value="0" selected>正常</option>
                                            <option value="1">头条</option>
                                            <option value="2">推荐</option>
                                            <option value="3">图文</option>
                                        {% elseif posts.flag == 1 then %}
                                            <option value="0">正常</option>
                                            <option value="1" selected>头条</option>
                                            <option value="2">推荐</option>
                                            <option value="3">图文</option>
                                        {% elseif posts.flag == 2 then %}
                                            <option value="0">正常</option>
                                            <option value="1">头条</option>
                                            <option value="2" selected>推荐</option>
                                            <option value="3">图文</option>
                                        {% elseif posts.flag == 3 then %}
                                            <option value="0">正常</option>
                                            <option value="1">头条</option>
                                            <option value="2">推荐</option>
                                            <option value="3" selected>图文</option>
                                        {% end %}
                                    </select>
                                </dd>
                            </dl>

                            <dl>
                                <dt>所属栏目：</dt>
                                <dd>
                                    <select name="cateid">
                                        {% for k, v in pairs(list) do %}
                                            {% if posts.cateid == v.cateId then %}
                                                <option value="{{v.cateId}}" selected>{{v.cateName}}</option>
                                            {% else %}
                                                <option value="{{v.cateId}}">{{v.cateName}}</option>
                                            {% end %}
                                        {% end %}
                                    </select>
                                </dd>
                            </dl>
                            <dl>
                                <dt>作者：</dt>
                                <dd><input type="text"  name="author"  value="{{posts.author}}" ></dd>
                            </dl>
                            <dl>
                                <dt>权重：</dt>
                                <dd><input type="text" name="weight" value="{{posts.weight}}"></dd>
                            </dl>

                            <dl>
                                <dt>点击量：</dt>
                                <dd><input type="text" name="click" value="{{posts.click}}"></dd>
                            </dl>

                            <dl>
                                <dt>缩略图：</dt>
                                <dd class="cl">
                                    <div class="upload-wrap">
                                        <div class="wrap-v1">
                                            <div class="wrap-v2" id="container_facade" uploadname="cFacade">
                                                <img id="litpic-show" src="{{posts.litpic}}"  />
                                            </div>
                                        </div>
                                        <label for="litpicfile" id="uploadBtn_facade">选择文件</label>
                                    </div>
                                    <p class="img-description">jpeg、png、jpg格式，3M以内</p>
                                    <p class="img-description"><a id="m-upload-btn"  class="normal">开始上传</a></p>
                                    <span id="imgerrormsg_facade" style="color:red"></span>
                                    <input type="file"  style="display: none;" id="litpicfile" name="litpicfile" />
                                    <input type="hidden" name="litpic"  id="litpic-source" value="{{posts.litpic}}">
                                </dd>
                            </dl>



                        </div>
                        <div class="verify-item-b">
                            <p class="title">搜索引擎设置</p>
                            <dl>
                                <dt>关键词：</dt>
                                <dd><input type="text" name="keywords" value="{{posts.keywords}}"></dd>
                            </dl>
                            <dl>
                                <dt>栏目描述：</dt>
                                <dd><input type="text" name="description" value="{{posts.description}}"></dd>
                            </dl>

                            <dl>
                                <dt>文章内容：</dt>
                                <dd><textarea style="width:600px;height:200px;;border: 1px solid #e7e7e7;" name="content">{{posts.content}}</textarea></dd>
                            </dl>

                            <button type="submit" class="submit" >提 交</button>
                        </div>
                    </form>

                </div>
            </div>
        </div>
        <!--列表样式2-->

    </div>
</div>

<script type="text/javascript" src="/static/js/jquery-1.7.1.js"></script>
<script type="text/javascript" src="/static/js/ajaxfileupload.js"></script>

<script type="text/javascript">
    $(function(){
        //选择文件之后执行上传
        $('#m-upload-btn').on('click', function() {
            console.log('选中文件');
            $.ajaxFileUpload({
                url:'/admin/upload',
                secureuri:false,
                fileElementId:'litpicfile',//file标签的id
                dataType: 'json',//返回数据的类型
                success: function (data, status) {
                    //把图片替换
                    //var obj = jQuery.parseJSON(data);
                    console.log(data);
                    console.log(status);
                    alert(data.msg);
                    if(data.success){
                        $("#litpic-source").val(data.path);
                        $("#litpic-show").attr('src',data.path).show();
                    }else {
                        $("#litpic-show").hide();
                    }
                },
                error: function (data, status, e) {
                    alert(e);
                }
            });
        });

    });
</script>
</body>
</html>